
<!DOCTYPE html>
<html>
	<head>
	<meta charset="utf-8">
	<title>Barcode Example</title>
	   <script src="js/mui.min.js"></script>
	<script type="text/javascript" >
// 扩展API加载完毕后调用onPlusReady回调函数 
document.addEventListener( "plusready", onPlusReady, false );
// 扩展API加载完毕，现在可以正常调用扩展API
function onPlusReady() {
	startRecognize();
	var e = document.getElementById("scan");
	e.removeAttribute( "disabled" );
}
var scan = null;
function onmarked( type, result ) {
	var text = '未知: ';
	switch(type){
		case plus.barcode.QR:
		text = 'QR: ';
		break;
		case plus.barcode.EAN13:
		text = 'EAN13: ';
		break;
		case plus.barcode.EAN8:
		text = 'EAN8: ';
		break;
	}
	alert( text+result );
}
function startRecognize() {
	scan = new plus.barcode.Barcode('bcid');
	scan.onmarked = onmarked; 
}
/*function start() {
	document.getElementById('bcid').addEventListener('tap', function() {
		  //打开关于页面
		  mui.openWindow({
		    url: 'index.html', 
		    id:'bcid',
		    show:{
		      autoShow:true,//页面loaded事件发生后自动显示，默认为true
		      aniShow:'zoom-out'//页面显示动画，默认为”slide-in-right“；
		    },
		  });
		});
}*/
function startScan() {
	scan.start();
}

	</script>
	<style type="text/css">
*{
	-webkit-user-select: none;
}
html,body{
	margin: 0px;
	padding: 0px;
	height: 100%;
}
#bcid {
	background:pink;
	height:590px;
	width:360px;
}
	</style>
	</head>
	<body >
		
	<!--	<input type="button" value="退出" onclick="start()" />-->
		
		
		<input type='button' onclick='startRecognize()' value='创建扫描控件' />
		<input type='button' onclick='startScan()' value='开始扫描' />
		<div id= "bcid"></div>
		
	</body>
</html>
